<template>
  <div class="bottom-nav-box cenCen">
    <van-tabbar class="maxWidth van-tabbar-self cursor" v-model="active">
      <van-tabbar-item v-if="role_type=='1'" @click="sureThisPage('myApprove')" name="myApprove" icon="manager-o">我审批的</van-tabbar-item>
      <van-tabbar-item @click="sureThisPage('assessment')" name="assessment" icon="completed">考核</van-tabbar-item>
      <van-tabbar-item @click="sureThisPage('score')" name="score" icon="records">评分</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      active: "assessment",
      role_type: "0" // role_type=0是普通员工没有我的审批,=1是领导有我的审批
    };
  },
  created() {
    this.role_type = sessionStorage.getItem("role_type") || "0";
    if (localStorage.getItem("thisPageActive")) {
      this.active = localStorage.getItem("thisPageActive");
    }
    this.sureThisPage(this.active);
  },
  methods: {
    sureThisPage(active) {
      if (active == "myApprove") {
        this.$openPage("/myApprove", {}, "replace");
      } else if (active == "assessment") {
        this.$openPage("/assessment", {}, "replace");
      } else if (active == "score") {
        this.$openPage("/score", {}, "replace");
      } else {
        this.sureThisPage("assessment");
      }
      this.active = active;
      localStorage.setItem("thisPageActive", active);
    }
  }
};
</script>

<style scoped>
.bottom-nav-box {
  position: fixed;
  left: 0px;
  bottom: 0px;
  z-index: 99;
  width: 100%;
  height: auto;
}

.van-tabbar-self {
  position: relative;
}
</style>
